package cn.juque.jdfsystem.inits;

import cn.juque.jdfsystem.cache.PlatformInfoCache;
import cn.juque.jdfsystem.cache.RegisterInfoCache;
import cn.juque.jdfsystem.config.JdfConfig;
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

/**
 * @author juque
 * @version 1.0.0
 * <ul>
 *     <li>JdfSystemInitRunner</li>
 * </ul>
 * @date 2023-01-10 23:57:13
 **/
@Slf4j
@Component
public class JdfSystemInitRunner implements ApplicationRunner {

    @Resource
    private RegisterInfoCache registerInfoCache;

    @Resource
    private PlatformInfoCache platformInfoCache;

    @Resource
    private JdfConfig jdfConfig;

    @Override
    public void run(ApplicationArguments args) {
        this.registerInfoCache.init();
        this.platformInfoCache.refresh();
        this.jdfConfig.setInitComplete(true);
        log.info("节点:{} 启动完成，绑定IP:{}", this.jdfConfig.getNodeName(), this.jdfConfig.getBindIp());
    }
}
